/*
** FileName:2951.c
** Author:Creat
** Time:下午7:40
** Date:2024/5/28
**/
#include <stdlib.h>
#include <string.h>
int* findPeaks(int* mountain, int mountainSize, int* returnSize) {
    int num = 0;
    int last_flag = 0;
    int* res = (int*)malloc(sizeof(int) * 100);
    memset(res, 0, sizeof(int) * 100);
    for(int i = 0;i < mountainSize - 1;i++){
        if(last_flag == 1){
            if(mountain[i] > mountain[i + 1]) {
                res[num++] = i;
                last_flag = 0;
            }else if(mountain[i] == mountain[i + 1]){
                last_flag = 0;
            }else{
                last_flag = 1;
            }
        }else{
            if(mountain[i] < mountain[i + 1]){
                last_flag = 1;
            }else;
        }
    }
    *returnSize = num;
    return res;
}